package schoolword3;
abstract class Animal{
    private String type;  // 动物类型

    public Animal(String type) {
        this.type = type;
    }

    public void show()  {

    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    abstract void talk();
}

 class Dog extends Animal{
    String name;  //狗的名字
   Dog(String type,String name) {
       super(type);
       this.name = name;
    }

    @Override
    public void show() {
        System.out.println("此动物属于" + getType() + ",名字是" + name);
    }

    @Override
    void talk() {
        System.out.println("叫声为旺旺!");
    }
}

  class Cat extends Animal{
    public String name;
    Cat(String type,String name) {
        super(type);
        this.name = name;
    }

     @Override
     public void show() {
         System.out.println("此动属于" + getType() + ",名字是" + name);
     }

     @Override
     void talk() {
         System.out.println("叫声为喵喵!");
     }
 }
public class Test {
    public static void main(String[] args) {
        Animal animal = new Dog("犬科动物","德国黑贝");
        Animal animal1 = new Cat("猫科动物","波斯猫");
        //打印狗的
        animal.show();
        animal.talk();

        //打印猫的
        animal1.show();
        animal1.talk();
    }
}
